<template>
    <div class="collectContent">
        <div class="collectBox">
            <div class="collectBoxItem" v-for="(item, index) in collectList" :key="item.id" @click="goCollectDetails(item)">
                <div class="collectItemMainBoxItemLeft">
                    <div class="collectItemMainBoxItemLeftIcon">
                        <SvgIcon width="40px" height="40px" :name="item.icon" color="#f5c3cb"></SvgIcon>
                    </div>
                    <div class="collectItemMainBoxItemLeftTitle">
                        <span class="collectItemMainBoxItemLeftTitle1">{{ item.title }}</span>
                        <span class="collectItemMainBoxItemLeftTitle2">{{ item.text }}</span>
                    </div>
                </div>
                <div class="collectItemMainBoxItemRight">
                    <van-icon name="arrow"size="20" />
                </div>
            </div>
        </div>
    </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { showToast, showFailToast } from 'vant'
import collectStore from '@/store/modules/collectDataList'
const collectDataStore = collectStore()

const route = useRoute()
const router = useRouter()

const collectList = ref<any>([])

const goCollectDetails = (item: any) => {
    if (item.path === '') {
        showToast('待完善...')
        return
    }
    router.push({
        path: item.path,
        query: {
            id: item.id,
            title: item.title
        }
    })
}

onMounted(() => {
    if (collectDataStore.collectDataList && collectDataStore.collectDataList.length > 0) {
        collectList.value = collectDataStore.collectDataList;
    } else {
        showFailToast('数据加载失败，请稍后再试！')
        router.back()
    }
})

</script>


<style lang="scss" scoped>
.collectContent {
    width: 100%;
    padding: 15px;
    .collectBox {
        width: 100%;
        padding: 0 5px;
        .collectBoxItem {
            width: 100%;
            height: 70px;
            background-color: var(--background);
            display: flex;
            flex-direction: row;
            align-items: center;
            justify-content: space-between;
            border-bottom: 0.5px solid #eee;
            .collectItemMainBoxItemLeft {
                height: 100%;
                display: flex;
                flex-direction: row;
                align-items: center;
                .collectItemMainBoxItemLeftIcon {
                    margin-right: 20px;
                }
                .collectItemMainBoxItemLeftTitle {
                    height: 100%;
                    display: flex;
                    flex-direction: column;
                    justify-content: space-around;
                    .collectItemMainBoxItemLeftTitle1 {
                        margin-top: 10px;
                        font-size: 14px;
                        font-weight: 500;
                    }
                    .collectItemMainBoxItemLeftTitle2 {
                        font-size: 12px;
                        color: rgb(128, 128, 128);
                        margin-bottom: 10px;
                    }
                }
            }
            .collectItemMainBoxItemRight {
                
            }
        }
    }
}
</style>